Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Theming] Fix tsc output #498

Merged

Conversation

michaeljaltamirano
Copy link
Contributor

@michaeljaltamirano michaeljaltamirano commented Nov 2, 2020

The changes in epic/add-theming-functionality changed a fair amount of scaffolding around on src files. The below screenshot shows the difference in lib outputs between this branch, the base branch, and master:

Screen Shot 2020-11-02 at 1 08 39 PM

The current behavior in master is to output all of the source in src without being nested in src, while the changes I've made resulted in the type declarations we emit to be nested in a src file. This broke current behavior in consumer apps, e.g. TypeScript could not infer the types of files imported from radiance-ui/lib/constants. This PR corrects that behavior by moving the new files in tests and types that were added in this branch nested within src, which corrects the output regression. (Hopefully the code comments + README committed in here are sufficient--if not please leave a comment about improvements!)

I tried another approach using Project References, but it didn't change the nesting issues.

Any other changes I will explain in the diff.

@@ -8,6 +8,7 @@
"dist",
"lib",
"lib/constants",
"lib/icons",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We import directly from here, so I think it should also be present here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it seems you have to manually specify the nested paths here so I don't know how it was working. I remember I had to specify in daylight exactly "files": [ "dist", "dist/static", "dist/static/media" ], otherwise it would not output the media folder . But whatever this seems consistent

@@ -30,7 +31,7 @@
"build:icons:deprecated": "svgr --expand-props none --template src/utils/svgToIconTemplate/index.js -d src/icons/ src/svgs/deprecated/",
"build:icons:index": "create-index src/icons/",
"build:rollup": "rollup -c",
"build:babel": "babel src -d lib --extensions '.js,.ts,.tsx'",
"build:babel": "babel src -d lib --extensions '.js,.ts,.tsx' --ignore '**/*.test.{js,ts,tsx}'",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We currently build test files, which seems unnecessary/inadvisable.

I got side-tracked a bit about keeping actual source vs. test separate, could be a good Cooldown item to get things up to Open Source Best Practices.

configure({ adapter: new Adapter() });

window.matchMedia =
window.matchMedia ||
function () {
return {
matches: false,
dispatchEvent: () => false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fleshed out these properties to remove the TypeScript error, and I guess related changes made the eslint stuff not matter anymore.

"emitDeclarationOnly": true,
"outDir": "lib",
"rootDirs": ["src"]
// The folder structure in outDir is based on "The longest common path of all non-declaration input files."
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments are valid json in tsconfig files 🙂

Copy link
Contributor

@daigof daigof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -8,6 +8,7 @@
"dist",
"lib",
"lib/constants",
"lib/icons",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it seems you have to manually specify the nested paths here so I don't know how it was working. I remember I had to specify in daylight exactly "files": [ "dist", "dist/static", "dist/static/media" ], otherwise it would not output the media folder . But whatever this seems consistent

@michaeljaltamirano michaeljaltamirano merged commit a2c465f into epic/add-theming-functionality Nov 2, 2020
@michaeljaltamirano michaeljaltamirano deleted the theming/fix-tsc-output branch November 2, 2020 20:22
michaeljaltamirano added a commit that referenced this pull request Nov 9, 2020
* [Theme setup] Initial setup and Accordion example (#436)

* initial setup

* convert Acoordion,add  theme suport to stories

* complete accordion example

* shouldShowForEnvironment refactor

* commit snapshot size

* v13.0.0-alpha.1

* Replace swap button with addon-toolbars to fix visual regression

Co-authored-by: Michael Altamirano <michaeljaltamirano@gmail.com>

* [Theming] Add built-in TypeScript support (#463)

* initial setup

* convert Acoordion,add  theme suport to stories

* complete accordion example

* shouldShowForEnvironment refactor

* commit snapshot size

* v13.0.0-alpha.1

* Commit example with Rollup + TypeScript resolution

* Commit hard-coded import

* Revert "Commit hard-coded import"

This reverts commit 9713df2.

* PR Cleanup

* Remove rollup plugin

* Move type resolution files out of utils and into types folder

* Commit master size-snapshot

* Push last size-snapshot

Co-authored-by: Diego Fortes <daigof@gmail.com>

* [Theming] Convert Component Usage (Part I) (#467)

* Convert for Accordion.Thumbnails

* Convert easy cases: styled component and normal component usage

* Add @types/enzyme-adapter-react-16

* Pass in blank string instead of undefined to maintain some semblance of distinction (for now)

* Convert setupTests.js to ts

* Get tests passing, check on chromatic

* [Theming] Convert Component Usage (Part II, Buttons) (#475)

* Bump @types/react from 16.9.53 to 16.9.55 (#473)

* Bump @types/react-dom from 16.9.8 to 16.9.9 (#469)

* Bump @types/enzyme from 3.10.7 to 3.10.8 (#470)

* Bump lint-staged from 10.4.0 to 10.5.0 (#468)

* Rename primary and secondary files to match default export name, export new COLORS_PROP_TYPES for aliased values

* Export values as const for type inference, add secondary tints for lavender usage in buttons

* Button update: add theming, constrict typing, remove unnecessary css imports (when in-lining in styled component)

* Update size snapshot, new items due to new COLORS_PROP_TYPES usage

* Decorate tests

* Add back base button css composition, since typography depends on it

* Tighten textColor typing, too

* Override prettier, TODO: use prettier-eslint

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* [Theming] Convert Components (Part III) (#476)

* Update global styles and storybook preview configuration

* Update Callout, Chip, LoadingSpinner, and ProgressBar

* Update DialogModal, Tabs, and Toggle

* Update Dropdown

* Update SelectorButton styles, modify eslint rule

* Convert COntainer, ImmersiveModal, OptionButton

* Last commits: Container and Field, and update .size-snapshot

* Rename prop to get off DOM

* [Theming] Convert Components (Part IV) (#477)

* Bump @types/react from 16.9.53 to 16.9.55 (#473)

* Bump @types/react-dom from 16.9.8 to 16.9.9 (#469)

* Bump @types/enzyme from 3.10.7 to 3.10.8 (#470)

* Bump lint-staged from 10.4.0 to 10.5.0 (#468)

* Rename primary and secondary files to match default export name, export new COLORS_PROP_TYPES for aliased values

* Export values as const for type inference, add secondary tints for lavender usage in buttons

* Button update: add theming, constrict typing, remove unnecessary css imports (when in-lining in styled component)

* Update size snapshot, new items due to new COLORS_PROP_TYPES usage

* Decorate tests

* Add back base button css composition, since typography depends on it

* Tighten textColor typing, too

* Override prettier, TODO: use prettier-eslint

* Commit Typography WIP, save for last

* Fix build, update .size-snapshot, replace all TYPOGRAPHY_STYLE usages, including story

* Reconfigure stories/tsconfig, export ThemeColors instead for improved DX

* Fix bizarre formatting

* Fix formatting pt. 2

* One last eslint fix and prettier write cleanup

* try running through eslint-plugin-prettier

* Conform to docs order

* Remove floating semicolons

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* [Theming] Update Colors Export (#480)

* Bump @types/react from 16.9.53 to 16.9.55 (#473)

* Bump @types/react-dom from 16.9.8 to 16.9.9 (#469)

* Bump @types/enzyme from 3.10.7 to 3.10.8 (#470)

* Bump lint-staged from 10.4.0 to 10.5.0 (#468)

* Bump typescript from 4.0.3 to 4.0.5 (#471)

* Bump chromatic from 5.2.0 to 5.3.0 (#478)

* Bump @react-aria/focus from 3.2.2 to 3.2.3 (#479)

* Mass commit: add TODO to existing COLORS export, fix lingering COLORS imports, update stories

* Add react-is as devDependency to fix install warning

* Fix visual regression in Available Constants story

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* v13.0.0-alpha.2

* [Theming] Fix tsc output (#498)

* Re-arrange new files for theming to fix lib type file structure

* Fix window.matchMedia type by fleshing it out

* v13.0.0-alpha.3

* [Theming] Update Test Suite (#505)

* [Theming] Update Declarations  (#504)

* Merge declaration changes from master

* Rename code comment

* Do not make Button onClick event potentially undefined

* Keep Dropdown value type consistent

* v13.0.0-alpha.4

* Push size changes, too

* Narrow ReactNode to JSX.Element in ImmersiveModal title

* Simplify generics usage

* Increase carousel story delay to prevent load jank from failing regression test

Co-authored-by: Diego Fortes <daigof@gmail.com>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
daigof added a commit that referenced this pull request Nov 9, 2020
* [Theme setup] Initial setup and Accordion example (#436)

* initial setup

* convert Acoordion,add  theme suport to stories

* complete accordion example

* shouldShowForEnvironment refactor

* commit snapshot size

* v13.0.0-alpha.1

* Replace swap button with addon-toolbars to fix visual regression

Co-authored-by: Michael Altamirano <michaeljaltamirano@gmail.com>

* [Theming] Add built-in TypeScript support (#463)

* initial setup

* convert Acoordion,add  theme suport to stories

* complete accordion example

* shouldShowForEnvironment refactor

* commit snapshot size

* v13.0.0-alpha.1

* Commit example with Rollup + TypeScript resolution

* Commit hard-coded import

* Revert "Commit hard-coded import"

This reverts commit 9713df2.

* PR Cleanup

* Remove rollup plugin

* Move type resolution files out of utils and into types folder

* Commit master size-snapshot

* Push last size-snapshot

Co-authored-by: Diego Fortes <daigof@gmail.com>

* [Theming] Convert Component Usage (Part I) (#467)

* Convert for Accordion.Thumbnails

* Convert easy cases: styled component and normal component usage

* Add @types/enzyme-adapter-react-16

* Pass in blank string instead of undefined to maintain some semblance of distinction (for now)

* Convert setupTests.js to ts

* Get tests passing, check on chromatic

* [Theming] Convert Component Usage (Part II, Buttons) (#475)

* Bump @types/react from 16.9.53 to 16.9.55 (#473)

* Bump @types/react-dom from 16.9.8 to 16.9.9 (#469)

* Bump @types/enzyme from 3.10.7 to 3.10.8 (#470)

* Bump lint-staged from 10.4.0 to 10.5.0 (#468)

* Rename primary and secondary files to match default export name, export new COLORS_PROP_TYPES for aliased values

* Export values as const for type inference, add secondary tints for lavender usage in buttons

* Button update: add theming, constrict typing, remove unnecessary css imports (when in-lining in styled component)

* Update size snapshot, new items due to new COLORS_PROP_TYPES usage

* Decorate tests

* Add back base button css composition, since typography depends on it

* Tighten textColor typing, too

* Override prettier, TODO: use prettier-eslint

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* [Theming] Convert Components (Part III) (#476)

* Update global styles and storybook preview configuration

* Update Callout, Chip, LoadingSpinner, and ProgressBar

* Update DialogModal, Tabs, and Toggle

* Update Dropdown

* Update SelectorButton styles, modify eslint rule

* Convert COntainer, ImmersiveModal, OptionButton

* Last commits: Container and Field, and update .size-snapshot

* Rename prop to get off DOM

* [Theming] Convert Components (Part IV) (#477)

* Bump @types/react from 16.9.53 to 16.9.55 (#473)

* Bump @types/react-dom from 16.9.8 to 16.9.9 (#469)

* Bump @types/enzyme from 3.10.7 to 3.10.8 (#470)

* Bump lint-staged from 10.4.0 to 10.5.0 (#468)

* Rename primary and secondary files to match default export name, export new COLORS_PROP_TYPES for aliased values

* Export values as const for type inference, add secondary tints for lavender usage in buttons

* Button update: add theming, constrict typing, remove unnecessary css imports (when in-lining in styled component)

* Update size snapshot, new items due to new COLORS_PROP_TYPES usage

* Decorate tests

* Add back base button css composition, since typography depends on it

* Tighten textColor typing, too

* Override prettier, TODO: use prettier-eslint

* Commit Typography WIP, save for last

* Fix build, update .size-snapshot, replace all TYPOGRAPHY_STYLE usages, including story

* Reconfigure stories/tsconfig, export ThemeColors instead for improved DX

* Fix bizarre formatting

* Fix formatting pt. 2

* One last eslint fix and prettier write cleanup

* try running through eslint-plugin-prettier

* Conform to docs order

* Remove floating semicolons

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* [Theming] Update Colors Export (#480)

* Bump @types/react from 16.9.53 to 16.9.55 (#473)

* Bump @types/react-dom from 16.9.8 to 16.9.9 (#469)

* Bump @types/enzyme from 3.10.7 to 3.10.8 (#470)

* Bump lint-staged from 10.4.0 to 10.5.0 (#468)

* Bump typescript from 4.0.3 to 4.0.5 (#471)

* Bump chromatic from 5.2.0 to 5.3.0 (#478)

* Bump @react-aria/focus from 3.2.2 to 3.2.3 (#479)

* Mass commit: add TODO to existing COLORS export, fix lingering COLORS imports, update stories

* Add react-is as devDependency to fix install warning

* Fix visual regression in Available Constants story

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* v13.0.0-alpha.2

* [Theming] Fix tsc output (#498)

* Re-arrange new files for theming to fix lib type file structure

* Fix window.matchMedia type by fleshing it out

* v13.0.0-alpha.3

* [Theming] Update Test Suite (#505)

* [Theming] Update Declarations  (#504)

* Merge declaration changes from master

* Rename code comment

* Do not make Button onClick event potentially undefined

* Keep Dropdown value type consistent

* v13.0.0-alpha.4

* Push size changes, too

* Narrow ReactNode to JSX.Element in ImmersiveModal title

* Simplify generics usage

* refactor fonts to theme

* add test

* refactor out test util function

* reafctor util tester

* [TypeScript] Replace ThemeType Absolute Imports with Relative Imports (#510)

* Move ThemeType (and associated imports) to relative imports instead of absolute

* Update .size-snapshot.json

Co-authored-by: Michael Altamirano <michaeljaltamirano@gmail.com>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
michaeljaltamirano added a commit that referenced this pull request Nov 10, 2020
* [Themes] - Add fonts to themes (#509)

* [Theme setup] Initial setup and Accordion example (#436)

* initial setup

* convert Acoordion,add  theme suport to stories

* complete accordion example

* shouldShowForEnvironment refactor

* commit snapshot size

* v13.0.0-alpha.1

* Replace swap button with addon-toolbars to fix visual regression

Co-authored-by: Michael Altamirano <michaeljaltamirano@gmail.com>

* [Theming] Add built-in TypeScript support (#463)

* initial setup

* convert Acoordion,add  theme suport to stories

* complete accordion example

* shouldShowForEnvironment refactor

* commit snapshot size

* v13.0.0-alpha.1

* Commit example with Rollup + TypeScript resolution

* Commit hard-coded import

* Revert "Commit hard-coded import"

This reverts commit 9713df2.

* PR Cleanup

* Remove rollup plugin

* Move type resolution files out of utils and into types folder

* Commit master size-snapshot

* Push last size-snapshot

Co-authored-by: Diego Fortes <daigof@gmail.com>

* [Theming] Convert Component Usage (Part I) (#467)

* Convert for Accordion.Thumbnails

* Convert easy cases: styled component and normal component usage

* Add @types/enzyme-adapter-react-16

* Pass in blank string instead of undefined to maintain some semblance of distinction (for now)

* Convert setupTests.js to ts

* Get tests passing, check on chromatic

* [Theming] Convert Component Usage (Part II, Buttons) (#475)

* Bump @types/react from 16.9.53 to 16.9.55 (#473)

* Bump @types/react-dom from 16.9.8 to 16.9.9 (#469)

* Bump @types/enzyme from 3.10.7 to 3.10.8 (#470)

* Bump lint-staged from 10.4.0 to 10.5.0 (#468)

* Rename primary and secondary files to match default export name, export new COLORS_PROP_TYPES for aliased values

* Export values as const for type inference, add secondary tints for lavender usage in buttons

* Button update: add theming, constrict typing, remove unnecessary css imports (when in-lining in styled component)

* Update size snapshot, new items due to new COLORS_PROP_TYPES usage

* Decorate tests

* Add back base button css composition, since typography depends on it

* Tighten textColor typing, too

* Override prettier, TODO: use prettier-eslint

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* [Theming] Convert Components (Part III) (#476)

* Update global styles and storybook preview configuration

* Update Callout, Chip, LoadingSpinner, and ProgressBar

* Update DialogModal, Tabs, and Toggle

* Update Dropdown

* Update SelectorButton styles, modify eslint rule

* Convert COntainer, ImmersiveModal, OptionButton

* Last commits: Container and Field, and update .size-snapshot

* Rename prop to get off DOM

* [Theming] Convert Components (Part IV) (#477)

* Bump @types/react from 16.9.53 to 16.9.55 (#473)

* Bump @types/react-dom from 16.9.8 to 16.9.9 (#469)

* Bump @types/enzyme from 3.10.7 to 3.10.8 (#470)

* Bump lint-staged from 10.4.0 to 10.5.0 (#468)

* Rename primary and secondary files to match default export name, export new COLORS_PROP_TYPES for aliased values

* Export values as const for type inference, add secondary tints for lavender usage in buttons

* Button update: add theming, constrict typing, remove unnecessary css imports (when in-lining in styled component)

* Update size snapshot, new items due to new COLORS_PROP_TYPES usage

* Decorate tests

* Add back base button css composition, since typography depends on it

* Tighten textColor typing, too

* Override prettier, TODO: use prettier-eslint

* Commit Typography WIP, save for last

* Fix build, update .size-snapshot, replace all TYPOGRAPHY_STYLE usages, including story

* Reconfigure stories/tsconfig, export ThemeColors instead for improved DX

* Fix bizarre formatting

* Fix formatting pt. 2

* One last eslint fix and prettier write cleanup

* try running through eslint-plugin-prettier

* Conform to docs order

* Remove floating semicolons

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* [Theming] Update Colors Export (#480)

* Bump @types/react from 16.9.53 to 16.9.55 (#473)

* Bump @types/react-dom from 16.9.8 to 16.9.9 (#469)

* Bump @types/enzyme from 3.10.7 to 3.10.8 (#470)

* Bump lint-staged from 10.4.0 to 10.5.0 (#468)

* Bump typescript from 4.0.3 to 4.0.5 (#471)

* Bump chromatic from 5.2.0 to 5.3.0 (#478)

* Bump @react-aria/focus from 3.2.2 to 3.2.3 (#479)

* Mass commit: add TODO to existing COLORS export, fix lingering COLORS imports, update stories

* Add react-is as devDependency to fix install warning

* Fix visual regression in Available Constants story

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* v13.0.0-alpha.2

* [Theming] Fix tsc output (#498)

* Re-arrange new files for theming to fix lib type file structure

* Fix window.matchMedia type by fleshing it out

* v13.0.0-alpha.3

* [Theming] Update Test Suite (#505)

* [Theming] Update Declarations  (#504)

* Merge declaration changes from master

* Rename code comment

* Do not make Button onClick event potentially undefined

* Keep Dropdown value type consistent

* v13.0.0-alpha.4

* Push size changes, too

* Narrow ReactNode to JSX.Element in ImmersiveModal title

* Simplify generics usage

* refactor fonts to theme

* add test

* refactor out test util function

* reafctor util tester

* [TypeScript] Replace ThemeType Absolute Imports with Relative Imports (#510)

* Move ThemeType (and associated imports) to relative imports instead of absolute

* Update .size-snapshot.json

Co-authored-by: Michael Altamirano <michaeljaltamirano@gmail.com>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* [Colors] Add 'transparent' color (#512)

* Add transparent as valid COLORS alias/value

Co-authored-by: Michael Altamirano <michaeljaltamirano@gmail.com>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants